﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

<title>Calculate ampacity</title>

<!-- jQuery library -->
<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript"></script>
<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js" type="text/javascript"></script>

<!-- no conflict for using in CMS such as Joomla -->
<script type="text/javascript">jQuery.noConflict();</script>

<!-- local scripts -->
<script language="javascript" type="text/javascript">
	
	// global variables
	var inputData = null;
	
	//go through the html feilds and collect input data
	//save all the input params into inputDataJSON associative array
	//and stringify the JSON object
	function getInputData() {
		var inputDataJSON = {};
		var fields = jQuery(":input").serializeArray();
		jQuery.each(fields, function(i, field){
			inputDataJSON[field['name']] = field['value'];
	    });
	    inputDataJSON['funcName'] = 'getAmpacityCdrName';
	    
	    inputData = JSON.stringify(inputDataJSON);
	}
	
	// MAIN function
	jQuery(function () {
	
		jQuery("#calculateBt").click(function() {
			getInputData();
			jsonData = inputData;
			//alert(jsonData);
			jQuery.ajax( 
			{ 
				type: 'POST', 
				url: 'php/controller/api.php', 
				dataType: 'json', 
				data: { jsonData: jsonData }, 
				success: function(data) {
					//alert(data);
					//var amp = data.amp;
					//alert(amp);
					
					cseNum = data.cseNum;
					towerNum = data.towerNum;
					cdrType = data.cdrType;
					windSpeed = data.windSpeed;
					windDirec = data.windDirec;
					relHumid = data.relHumid;
					precipRate = data.precipRate;
					airPres = data.airPres;
					swRad = data.swRad;
					lwRad = data.lwRad;
					emissivity = data.emissivity;
					solarAbs = data.solarAbs;
					initCdrTemp = data.initCdrTemp;
					maxCdrTemp = data.maxCdrTemp;
					ambientTemp = data.ambientTemp;

					
					jQuery("#answerDiv").empty();
					//jQuery("#answerDiv").append("<p> Ampacity: "+amp+" A </p>");
					jQuery("#answerDiv").append("<p> "+cseNum+" "+ambientTemp+" "+windSpeed+" "+windDirec+" "+relHumid+" "+precipRate+" "+airPres+" "+swRad+" "+lwRad+" "+cdrType+" "+initCdrTemp+" "+maxCdrTemp+" "+emissivity+" "+solarAbs+" "+towerNum + "</p>");
				}
			});
		});
	});


</script>

</head>

<body>


<form method="post" action="">
<table>
	<tr>
		<td>Case Number:</td>
		<td>
			<input name="cseNum" type="text" value="1" />
		</td>
	</tr>
</table>

<h3>Weather Parameters:</h3>
<table>
	<tr>
		<td>Ambient temperature, °C:</td>
		<td>
			<input name="ambientTemp" type="text" value="5" />
		</td>
	</tr>
	<tr>
		<td>Wind speed, m/s:</td>
		<td>
			<input name="windSpeed" type="text" value="10" />
		</td>
	</tr>
	<tr>
		<td>Wind direction, deg:</td>
		<td>
			<input name="windDirec" type="text" value="15" />
		</td>
	</tr>
	<tr>
		<td>Relative humidity, %:</td>
		<td>
			<input name="relHumid" type="text" value="20" />
		</td>
	</tr>
	<tr>
		<td>Precip rate, mm/h:</td>
		<td>
			<input name="precipRate" type="text" value="25" />
		</td>
	</tr>
	<tr>
		<td>Air pressure, Pa:</td>
		<td>
			<input name="airPres" type="text" value="30" />
		</td>
	</tr>
	<tr>
		<td>Short wave radiation, W/m2:</td>
		<td>
			<input name="swRad" type="text" value="35" />
		</td>
	</tr>
	<tr>
		<td>Long wave radiation, W/m2:</td>
		<td>
			<input name="lwRad" type="text" value="40" />
		</td>
	</tr>





</table>
<h3>Conductor Parameters:</h3>
<table>
	<tr>
		<td>Conductor type:</td>
		<td>
			<input name="cdrType" type="text" value="45" />
		</td>
	</tr>
	<tr>
		<td>Initial conductor temperature:</td>
		<td>
			<input name="initCdrTemp" type="text" value="50" />
		</td>
	</tr>
	<tr>
		<td>Maximum allowable conductor temperature, °C:</td>
		<td>
			<input name="maxCdrTemp" type="text" value="55" />
		</td>
	</tr>
	<tr>
		<td>Conductor diameter, mm:</td>
		<td>
			<input name="dCdr" type="text" value="" disabled="disabled" />
		</td>
	</tr>
	<tr>
		<td>Minimum conductor temperature, °C:</td>
		<td>
			<input name="tMinCdr" type="text" value="" disabled="disabled" />
		</td>
	</tr>
	<tr>
		<td>Maximum conductor temperature, °C:</td>
		<td>
			<input name="tMaxCdr" type="text" value="" disabled="disabled" />
			</td>
	</tr>
	<tr>
		<td>Minimum conductor rac, ohms/km</td>
		<td>
			<input name="rMinCdr" type="text" value="" disabled="disabled" /></td>
	</tr>
	<tr>
		<td>Maximum conductor resistance, ohms/km</td>
		<td>
			<input name="rMaxCdr" type="text" value="" disabled="disabled" /></td>
	</tr>
	<tr>
		<td>Coefficient of emissivity</td>
		<td>
			<input name="emissivity" type="text" value="60" /></td>
	</tr>
	<tr>
		<td>Coefficient of solar absorption</td>
		<td>
			<input name="solarAbs" type="text" value="65" /></td>
	</tr>
</table>

<h3>Geographic Parameters:</h3>
<table>
	<tr>
		<td>Tower number:</td>
		<td>
			<input name="towerNum" type="text" value="70" />
		</td>
	</tr>

	<tr>
		<td>Latitude, degree:</td>
		<td>
			<input name="lat" type="text" value="" disabled="disabled" />
		</td>
	</tr>
	<tr>
		<td>Elevation above sea level, m:</td>
		<td>
			<input name="elev" type="text" value="" disabled="disabled" />
		</td>
	</tr>
	<tr>
		<td>Line direction (heading), deg:</td>
		<td>
			<input name="heading" type="text" value="" disabled="disabled" />
			</td>
	</tr>
</table>
<input type="button" value="Calculate" id="calculateBt" />
</form>

<div id="answerDiv"></div>


</body>

</html>
